using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Watchwords
{
    public partial class OptionsDialog : Form
    {
        private string _SelectedLanguage = string.Empty;
        public string SelectedLanguage
        {
            get
            {
                return _SelectedLanguage;
            }
            set
            {
                _SelectedLanguage = value;
                foreach (object o in cmbLanguage.Items)
                {
                    if (o.ToString().Substring(0,2) == value)
                    {
                        cmbLanguage.SelectedItem = o;
                        break;
                    }
                }
            }
        }

        public OptionsDialog()
        {
            InitializeComponent ();
        }

        

        private void button1_Click( object sender, EventArgs e )
        {
            if (cmbLanguage.SelectedItem.ToString ().Length > 0)
            {
                SelectedLanguage = cmbLanguage.SelectedItem.ToString ().Substring ( 0, 2 );
            }
            this.DialogResult = DialogResult.OK;
            Close ();
        }

        private void button2_Click( object sender, EventArgs e )
        {
            SelectedLanguage = string.Empty;
            this.DialogResult = DialogResult.Cancel;
            Close ();
        }

        private void cmbLanguage_SelectedIndexChanged( object sender, EventArgs e )
        {
            if (cmbLanguage.SelectedItem.ToString ().Length > 0)
            {
                SelectedLanguage = cmbLanguage.SelectedItem.ToString ().Substring ( 0, 2 );
            }
        }
    }
}